package com.stylefeng.guns.common.dto.acct;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

/**
 * @author carloszhang
 */
@Data
@ApiModel("账户注册请求")
public class AcctRegisterReq {

    @ApiModelProperty(value = "手机号",required = true)
    @NotEmpty
    @Pattern(regexp = "^1[3|4|5|6|7|8|9][0-9]\\d{8}$")
    private String mobileNo;

    @ApiModelProperty(value = "短信验证码",required = true)
    @NotEmpty
    private String smsCode;

    @ApiModelProperty(value = "密码",required = true)
    @NotEmpty
    private String cipher;

    @ApiModelProperty("邀请码,可空")
    @Size(max = 5)
    private String inviteCode;

    @ApiModelProperty("图形验证码,可空")
    private String kaptcha;

    public String getInviteCode() {
        if (StringUtils.isBlank(inviteCode)) {
            return StringUtils.EMPTY;
        }
        return inviteCode.toUpperCase();
    }
}
